package com.wangjie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wangjie.entity.Appointment;
import com.wangjie.service.AppointmentService;
import com.wangjie.mapper.AppointmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppointmentServiceImpl extends ServiceImpl<AppointmentMapper, Appointment> implements AppointmentService {
    @Autowired
    private AppointmentMapper appointmentMapper;

    /**
     * 查询预约信息是否存在
     *
     * @param appointment
     * @return
     */
    @Override
    public Appointment getOne(Appointment appointment) {
        LambdaQueryWrapper<Appointment> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Appointment::getUsername, appointment.getUsername());
        wrapper.eq(Appointment::getIdCard, appointment.getIdCard());
        wrapper.eq(Appointment::getDepartment, appointment.getDepartment());
        wrapper.eq(Appointment::getDate, appointment.getDate());
        wrapper.eq(Appointment::getTime, appointment.getTime());

        Appointment entity = appointmentMapper.selectOne(wrapper);
        return entity;
    }
}